package groupby.util;

import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import system.manage.SystemManageImpl;
import system.model.SystemInfor;

public class ConfigListener implements ServletContextListener,
		ServletContextAttributeListener {
	
	private ServletContext application = null ; 
	  
	private HttpSession session = null ;
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void contextInitialized(ServletContextEvent sce) {
	  ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
		System.out.println("采集器初始化!");
		context.getBean("startQuertz");
		System.out.println("初始化网站!");
		this.application=sce.getServletContext() ; 
		      
		
		SystemManageImpl smi=new SystemManageImpl();
		String path = application.getRealPath("/WEB-INF/classes/system.xml");
		SystemInfor systemInfor=smi.systemInfor(path);
		
		   
		this.application.setAttribute("systemInfor", systemInfor) ;

	}

	public void attributeAdded(ServletContextAttributeEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void attributeRemoved(ServletContextAttributeEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void attributeReplaced(ServletContextAttributeEvent arg0) {
		// TODO Auto-generated method stub

	}

}
